home *** CD-ROM | disk | FTP | other *** search
/ Games of Daze / Infomagic - Games of Daze (Summer 1995) (Disc 1 of 2).iso / djgpp / drivers / speav7m.asm < prev    next >
Encoding:
Assembly Source File  |  1994-07-18  |  7.0 KB  |  268 lines

  1. ; This is file SpeaV7M.ASM , derived from video7.asm
  2. ;
  3. ; Copyright (C) 1991 DJ Delorie, 24 Kirsten Ave, Rochester NH 03867-2954
  4. ;
  5. ; This file is distributed under the terms listed in the document
  6. ; "copying.dj", available from DJ Delorie at the address above.
  7. ; A copy of "copying.dj" should accompany this file; if not, a copy
  8. ; should be available from where this file was obtained.  This file
  9. ; may not be distributed without a verbatim copy of "copying.dj".
  10. ;
  11. ; This file is distributed WITHOUT ANY WARRANTY; without even the implied
  12. ; warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  13. ;
  14.  
  15. cseg    segment byte public 'code'
  16.         assume  cs:cseg, ds:cseg, es:cseg, ss:nothing
  17.  
  18.         dw      offset init_routine
  19.         dw      offset paging_routine
  20.         dw      0       ; set to 1 if separate read & write windows or
  21.                         ; only 64K of video RAM (ie: no paging)
  22.  
  23. def_tw  dw      80      ; filled in by go32 if GO32 env. var. is set
  24. def_th  dw      25
  25. def_gw  dw      1024
  26. def_gh  dw      768
  27.  
  28. ;--------------------------------------------------------------------------
  29. ; Entry: AX=mode selection
  30. ;               0=80x25 text
  31. ;               1=default text
  32. ;               2=text CX cols by DX rows
  33. ;               3=biggest text
  34. ;               4=320x200 graphics
  35. ;               5=default graphics
  36. ;               6=graphics CX width by DX height
  37. ;               7=biggest non-interlaced graphics
  38. ;               8=biggest graphics
  39. ;
  40. ; NOTE: This runs in real mode, but don't mess with the segment registers.
  41. ;
  42. ; Exit:  CX=width (in pixels or characters)
  43. ;        DX=height
  44.  
  45. init_table      label   word
  46.         dw      offset init_0
  47.         dw      offset init_1
  48.         dw      offset init_2
  49.         dw      offset init_3
  50.         dw      offset init_4
  51.         dw      offset init_5
  52.         dw      offset init_6
  53.         dw      offset init_7
  54.         dw      offset init_8
  55.  
  56. init_routine    proc    far
  57.         cmp     ax,8
  58.         jbe     valid_req
  59.         ret
  60. valid_req:
  61.         shl     ax,1
  62.         mov     bx,ax
  63.         jmp     init_table[bx]
  64.  
  65. init_0: ; 80x25 text
  66.         mov     ax,3
  67.         int     10h
  68.         mov     cx,80
  69.         mov     dx,25
  70.         ret
  71.  
  72. init_1: ; default text
  73.         mov     cx,def_tw
  74.         mov     dx,def_th
  75.         jmp     init_2
  76.  
  77. init_2_table    label   word
  78.         dw       01h, 40, 25
  79.         dw       03h, 80, 25
  80.         dw       55h,132, 25
  81.         dw       54h,132, 43
  82. init_2_tend     label   word
  83.  
  84. init_2: ; CX*DX text
  85.         mov     si,offset init_2_table
  86. init_2a:
  87.         cmp     [si+2],cx
  88.         jb      init_2b
  89.         cmp     [si+4],dx
  90.         jb      init_2b
  91.         ; got a big enough one!
  92.         jmp     init_2c
  93. init_2b:
  94.         cmp     si,offset init_2_tend - 6
  95.         je      init_2c
  96.         add     si,6
  97.         jmp     init_2a
  98. init_2c:
  99.         mov     ax,[si]
  100.         push    si
  101.         int     10h
  102.         pop     si
  103.         mov     cx,[si+2]
  104.         mov     dx,[si+4]
  105.         ret
  106.  
  107. init_3: ; biggest text
  108.         mov     ax,[init_2_tend-6]
  109.         int     10h
  110.         mov     cx,[init_2_tend-4]
  111.         mov     dx,[init_2_tend-2]
  112.         ret
  113.  
  114. init_4: ; 320x200 graphics
  115.         mov     ax,13h
  116.         int     10h
  117.         mov     cx,320
  118.         mov     dx,200
  119.         ret
  120.  
  121. init_5: ; default graphics - should be 640x480 if supported
  122.         mov     cx,def_gw
  123.         mov     dx,def_gh
  124.         jmp     init_6
  125.  
  126. ;
  127. ; VESA-Modi:
  128. ;
  129. ;init_6_table   label   word
  130. ;       dw       13h, 320, 200
  131. ;       dw       49h, 640, 480
  132. ;       dw       6Bh, 800, 600
  133. ;       dw       6Ch,1024, 768
  134. ;       dw       3Fh,1152, 870
  135. ;init_6_tend    label   word
  136. ;
  137.  
  138. init_6_table    label   word
  139.         dw       13h, 320, 200
  140.         dw      201h, 640, 480
  141.         dw      203h, 800, 600
  142.         dw      205h,1024, 768
  143. init_6_tend     label   word
  144.  
  145. init_6: ; CX*DX graphics
  146.         mov     si,offset init_6_table
  147. init_6a:
  148.         cmp     [si+2],cx
  149.         jb      init_6b
  150.         cmp     [si+4],dx
  151.         jb      init_6b
  152.         ; got a big enough one!
  153.         jmp     init_6c
  154. init_6b:
  155.         cmp     si,offset init_6_tend - 6
  156.         je      init_6c
  157.         add     si,6
  158.         jmp     init_6a
  159. init_6c:
  160.         mov     ax,[si]
  161.         push    si
  162.         cmp     ax,13h
  163.         je      usual_way
  164.         mov     bx,ax
  165.         mov     ax,4f02h     ; VESA - modus einschalten : Function 4f, Subfunction 02
  166.         int     10h
  167.         pop     si
  168.         mov     cx,1024
  169.         mov     dx,[si+4]
  170.         ret
  171. usual_way:
  172.         int     10h
  173.         pop     si
  174.         mov     cx,[si+2]
  175.         mov     dx,[si+4]
  176.         ret
  177.  
  178. init_7: ; biggest non-interlaced graphics
  179.         mov     ax,4f02h
  180.         mov     bx,203h
  181.         int     10h
  182.         mov     cx,1024
  183.         mov     dx,600
  184.         ret
  185.  
  186. init_8: ; biggest graphics
  187.         mov     ax,4f02h
  188.         mov     bx,205h
  189.         int     10h
  190.         mov     cx,1024
  191.         mov     dx,768
  192.         ret
  193.  
  194. init_routine    endp
  195.  
  196. ;--------------------------------------------------------------------------
  197. ; Entry: AH=read page
  198. ;        AL=write page
  199. ;
  200. ; NOTE: This runs in protected mode!  Don't mess with the segment registers!
  201. ; This code must be relocatable and may not reference any data!
  202. ;
  203. ; Exit: VGA configured.
  204. ;       AX,BX,CX,DX,SI,DI may be trashed
  205. ;
  206. ; Code derived from Video7.ASM by Andy Thaller
  207. ;
  208. ;
  209. ; index = 03d4h
  210. ; data  = 03d5h
  211. ; bank-select-register: 35h
  212. ; low-nibble of bank-register = bit 16 to 19 of screenadress
  213. ;
  214. ; Unlock: write 48h to lock1-register at index 38h
  215. ;
  216. ; Write bank to select-register
  217. ; activate Bankswitching: set bit 0 in memory_config-reg. at index 31h
  218. ;
  219. ; Relock: write xxh to lock1-register at index 38h
  220. ;
  221. ;
  222.  
  223.  
  224.         assume  ds:nothing, es:nothing
  225.  
  226. paging_routine  proc    far
  227.         mov     ch,al
  228.  
  229.         mov     dx,3d4h
  230.         mov     al,038h
  231.         out     dx,al    ; select Lock1-register
  232.         mov     dx,3d5h
  233.         mov     ax,00048h
  234.         out     dx,ax    ; Unlock Paging registers via Lock1-register
  235.  
  236.         mov     dx,3d4h
  237.         mov     al,035h
  238.         out     dx,al    ; select Bank-select-register
  239.         mov     dx,3d5h
  240.         in      ax,dx    ; Read content: Bits 4-7 must not be changed
  241.       and     al,0f0h
  242.       or      al,ch
  243.         out     dx,ax    ; write bank to select
  244.  
  245.         mov     dx,3d4h
  246.         mov     al,031h
  247.         out     dx,al    ; select memory_config-register
  248.         mov     dx,3d5h
  249.         mov     ax,00048h
  250.         in      ax,dx    ; Read content: only bit 0 has to be set
  251.       or      ax,01h
  252.         out     dx,ax    ; activate bank-switching
  253.  
  254.         mov     dx,3d4h
  255.         mov     al,038h
  256.         out     dx,al    ; select Lock1-register
  257.         mov     dx,3d5h
  258.         mov     ax,00000h
  259.         out     dx,ax    ; relock Paging registers via Lock1-register
  260.         ret
  261. paging_routine  endp
  262.  
  263. ;--------------------------------------------------------------------------
  264.  
  265. cseg    ends
  266.         end
  267.  
  268.